import Vue from 'vue'
// VueAxios Axios
import VueAxios from 'vue-axios'
import Axios from 'axios'
// ElementUI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import App from './App.vue'

import router from "./router";
import store from "./store";

Axios.defaults.headers.post['Content-Type'] = 'application/json; charset=UTF-8'

// 请求拦截器
Axios.interceptors.request.use(config => {
  var user = Vue.prototype.$ENV
  if (user) {
    config.headers['H-userId'] = user.userId
    config.headers['H-token'] = user.token
  }
  return config;
}, error => {
  return Promise.reject(error);
});

// 响应拦截器
Axios.interceptors.response.use(response => {
  return response;
}, error => {
  return Promise.reject(error);
});

Vue.use(VueAxios, Axios)
Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
